{% extends "dashboard/base.html" %}
{% load i18n %}
{% load materializecss %}
{% load staticfiles %}

{% block title %}
  {% if stock.pk %}
    {% blocktrans trimmed with variant_name=stock.variant.name location=stock.location context "Dashboard stock" %}
      Stock {{ variant_name }} - {{ location }}
    {% endblocktrans %}
  {% else %}
    {% trans "Add stock" context "Stock form page title" %}
  {% endif %}
   - {{ block.super }}
{% endblock %}

{% block body_class %}body-store body-products{% endblock %}

{% block menu_products_class %}active{% endblock %}

{% block header_menu %}
  {% url "dashboard:product-update" pk=product.pk as url %}
  {% include "dashboard/includes/_back-link.html" with url=url hash="#stock" %}
{% endblock %}

{% block breadcrumbs %}
  <ul class="breadcrumbs breadcrumbs--history">
    <li>
      <a href="{% url "dashboard:product-list" %}" class="breadcrumb">
        {% trans "Products" context "Dashboard products list" %}
      </a>
    </li>
    <li class="back-mobile">
      <a href="{% url "dashboard:product-update" pk=product.pk %}#stock">
        <svg data-src="{% static "dashboard/images/chevron_left.svg" %}" />
      </a>
    </li>
    <li>
      <a href="{% url "dashboard:product-update" pk=product.pk %}#stock" class="breadcrumbs--ellipsed-item">
        {{ product }}
      </a>
    </li>
    {% if stock.pk %}
    <li>
      <span class="breadcrumbs--ellipsed-item">
        {% blocktrans trimmed with variant=stock.variant context "Dashboard stock" %}
          Stock {{ variant }}
        {% endblocktrans %}
      </span>
    </li>
    {% else %}
    <li>
      <span class="hide-on-med-and-down breadcrumbs--ellipsed-item">
        {% trans "Add stock" context "Stock form breadcrumbs" %}
      </span>
      <span class="hide-on-large-only breadcrumbs--ellipsed-item">
        {% blocktrans trimmed context "Stock form breadcrumbs" %}
        Add stock for {{ product }}
        {% endblocktrans %}
      </span>
    </li>
    {% endif %}
  </ul>
{% endblock %}

{% block menu_catalogue_class %} active{% endblock %}

{% block content %}
  <div class="row">
    <div class="col s12 m9">
      <div class="card">
        <form method="post" id="form-stock" enctype="multipart/form-data">
          <div class="card-content">
            {% csrf_token %}
            <input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#stock">
            <div class="row">
              <div class="col s12 m8">
                <div class="row">
                  {{ form.variant|materializecss }}
                </div>
                <div class="row">
                  {{ form.location|materializecss }}
                </div>
              </div>
              <div class="col s12 m4">
                <div class="row">
                  {{ form.quantity|materializecss }}
                </div>
                <div class="row">
                  {{ form.cost_price|materializecss }}
                </div>
              </div>
            </div>
          </div>
          <div class="card-action right-align">
            {% if stock.pk %}
              <a href="{% url "dashboard:product-update" pk=product.pk %}#stock" class="btn btn-flat">
                {% trans "Cancel" context "Dashboard cancel action" %}
              </a>
              <button type="submit" class="btn waves-effect waves-light">
                {% trans "Update" context "Dashboard update action" %}
              </button>
            {% else %}
              <a href="{% url "dashboard:product-update" pk=product.pk %}#stock" class="btn btn-flat">
                {% trans "Cancel" context "Dashboard cancel action" %}
              </a>
              <button type="submit" class="btn waves-effect waves-light">
                {% trans "Create" context "Dashboard create action" %}
              </button>
            {% endif %}
          </div>
        </form>
      </div>
    </div>
    <div class="col s12 m3 help-box"></div>
  </div>
{% endblock %}
